package com.bawei.module_mine

import android.app.Application
import android.content.Context
import com.bawei.module_mine.websocket.WebSocketUtils


open class BaseApplication:Application() {

    override fun onCreate() {
        super.onCreate()
        context =this.applicationContext
        // 初始化MultiDex
//        MultiDex.install(this)
    }

    companion object{
        private lateinit var context: Context
        fun getAppContext():Context{
            return context
        }

        private var websocket:WebSocketUtils?=null
        @JvmOverloads
        fun getWebSocket(listener:WebSocketUtils.ReceiveMsgListener):WebSocketUtils {
           if(websocket==null){
               websocket = WebSocketUtils.Builder()
//                   .setWebsocket_url("rtmp://58.200.131.2:1935/livetv/cctv1")
                   .setListener(listener)
                   .build()
           }

            return websocket!!
        }

        fun getWS(): WebSocketUtils? {

            return websocket
        }
        fun initWebSocket(listener: WebSocketUtils.ReceiveMsgListener) {
            if (websocket == null) {
                websocket = WebSocketUtils.Builder()
//                    .setWebsocket_url("rtmp://58.200.131.2:1935/livetv/cctv1")
                    .setListener(listener)
                    .build()
            }
        }
    }
}